package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_exchange_center")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.ExchangeCenterMapper")
public class ExchangeCenterDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 交易中心编码
     */
    @TableField(value = "center_code")
    private String centerCode;

    /**
     * 交易中心名称
     */
    @TableField(value = "center_name")
    private String centerName;

    /**
     * 联系人
     */
    @TableField(value = "linkman")
    private String linkman;

    /**
     * 联系人电话
     */
    @TableField(value = "linkman_mobile")
    private String linkmanMobile;

    /**
     * 对接中心接口地址
     */
    @TableField(value = "post_url")
    private String postUrl;

    /**
     * 联系地址
     */
    @TableField(value = "address")
    private String address;

    /**
     * 变更时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 变更用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    public ExchangeCenterVo buildVo() {
        return new ExchangeCenterVo(id, centerCode, centerName, linkman, linkmanMobile, postUrl, address, gmtCreate, gmtModified, userCreate, userModified);
    }

    public static ExchangeCenterDO of(ExchangeCenterVo vo) {
        return new ExchangeCenterDO(vo.getId(), vo.getCenterCode(), vo.getCenterName(), vo.getLinkman(), vo.getLinkmanMobile(), vo.getPostUrl(), vo.getAddress(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified());
    }
}
